<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page	import="java.util.*,com.grep.extra.dao.impl.ContentParseDao,com.grep.extra.dao.impl.ContentParseFieldDao,com.grep.extra.factory.data.impl.ContentParseField,com.grep.web.manager.FenYe"%>
<%
	String index = request.getParameter("index");
	String pagenum = request.getParameter("pagenum");
	String taskid = request.getParameter("taskid");
	
	int suoyin = Integer.parseInt(index);
	int pagesize = Integer.parseInt(pagenum);
	
	ContentParseDao contentParse = new ContentParseDao();

	String contentParseID = contentParse.getIdforTaskId(taskid);

	ContentParseFieldDao cpfd = new ContentParseFieldDao();

	int count = cpfd.getFieldCountByContentParseID(contentParseID);

	List<ContentParseField> list = new ArrayList<ContentParseField>();
	
	FenYe fenye = new FenYe();
	
	list = fenye.getTaskZhiBiaoFenYeData(contentParseID,suoyin,pagesize);

	String responseText = "[";

	for (int i = 0; i < list.size(); i++) {

		ContentParseField cpf = new ContentParseField();
		cpf = list.get(i);

		String id = cpf.getId();
		String field_name = cpf.getFieldName();
		String start_regex = cpf.getStartRegex();
		String end_regex = cpf.getEndRegex();

		if (i == list.size() - 1) {
			responseText += "{\"id\":\"" + id + "\",\"field_name\": \""
					+ field_name + "\",\"start_regex\": \""
					+ start_regex + "\",\"end_regex\": \"" + end_regex
					+ "\",\"count\": \"" + count + "\"}";
		} else {
			responseText += "{\"id\":\"" + id + "\",\"field_name\": \""
					+ field_name + "\",\"start_regex\": \""
					+ start_regex + "\",\"end_regex\": \"" + end_regex
					+ "\"},";
		}
	}

	responseText += "]";
	response.getWriter().println(responseText);
%>